const path = require("path");
const htmlWebpackPlugin = require("html-webpack-plugin")

// commonjs规范
module.exports = {
    mode: 'development',
    // 入口的js文件
    entry: "./src/index.js",
    output: {
        // 拼接绝对路径
        path: path.resolve(__dirname, "dist"),
        filename: "bundle.js"
    },
    module: {
        rules: [
            // css-loader 解析css源代码 style-loader（）
            // loader 加载器是从后向前执行。
            {test:/\.css$/, use: ['style-loader', 'css-loader']},
            {
                test: /\.less$/,
                use: ["style-loader", "css-loader", "less-loader"]
            },
            {
                test: /\.(jpeg|jpg|png|woff|svg|gif|webp)$/,
                // 1024字节
                // use: "url-loader?limit=1024"
                use: "url-loader"
            }
        ]
    },
    plugins: [
        new htmlWebpackPlugin({
            template: "./index.html"
        })
    ]
}